package com.wlz;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author： wlz
 * @Date 2020/6/23 10:06
 * @description： TODO
 * @version: 1.0
 */

@SpringBootApplication
public class ConfigApplication {

    private static final String CONFIG_NAME_VALUE = "application,dubbo";

    public static void main(String[] args) {

        System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY,CONFIG_NAME_VALUE);

        SpringApplication.run(ConfigApplication.class,args);
    }

//    @Component
//    @Order(1)
//    public class NioEndpointPropertiesCommandLineRunner implements CommandLineRunner {
//
//        @Autowired
//        private NioEndpointProperties nioEndpointProperties;
//
//        @Override
//        public void run(String... args) {
//            System.out.println(nioEndpointProperties);
//        }
//
//    }

    @Component
    @Order(2)
    public class ValueCommandLineRunner implements CommandLineRunner {

        @Value("${nio.endpoint.max-threads}")
        private Integer maxThreads;

        @Value("${nio.endpoint.connect-timeout}")
        private Integer connectTimeout;

        @Value("${application-test}")
        private String applicationTest;

        @Value("${dubbo-test}")
        private String dubboTest;

        @Override
        public void run(String... args) {
            System.out.println("maxThreads:" + maxThreads+",connectTimeout:" + connectTimeout);

            System.out.println(dubboTest+","+applicationTest);
        }

    }



}
